package com.vecspace.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class HttpContext {
	HttpServletRequest request;
	HttpServletResponse response;
	private String basePath;
	
	public HttpServletRequest getHttpRequest() {
		return request;
	}
	public void setHttpRequest(HttpServletRequest request) {
		this.request = request;
		String path = request.getContextPath();
		basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	}
	
	public HttpServletResponse getHttpResponse() {
		return response;
	}
	public void setHttpResponse(HttpServletResponse response) {
		this.response = response;
	}
	
	public HttpSession getHttpSession(){
		if(request == null) {
			return null;
		}
		return request.getSession();
	}
	
	/** 返回url的前缀:http://host:port/pms/
	 * 
	 * @return 
	 * @author: wanghua
	 */
	public String getBasePath(){
		return basePath;
	}
}
